$(function() {
    
    //Autocompletado obras sociales
    var obras_sociales_array=[];
    
    base_url = $('#base_url').val();   
    //AJAX
    $.ajax({
        url: base_url+"pacientes/obras_sociales_list/",
        success: function(msg) {            
            obras_sociales_array=msg.split('-');
            $( "#os_nombre" ).autocomplete({
                source: obras_sociales_array
            });
                
        }
    })
    
    //Autocompletado localidades
    var localidades_array=[];
    
    base_url = $('#base_url').val();   
    //AJAX
    $.ajax({
        url: base_url+"pacientes/localidades_list/",
        success: function(msg) {            
            localidades_array=msg.split('-');
            $( "#p_localidad" ).autocomplete({
                source: localidades_array
            });
                
        }
    })
    
    //Calendario
    $( "#c_fecha_cirugia_desde" ).datepicker({
        dateFormat: "dd-mm-yy",
        changeMonth: true,
        changeYear: true,
        dayNamesMin: [ "Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa" ],
        monthNamesShort: [ "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic" ]

    });
    //Calendario
    $( "#c_fecha_cirugia_hasta" ).datepicker({
        dateFormat: "dd-mm-yy",
        changeMonth: true,
        changeYear: true,
        dayNamesMin: [ "Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa" ],
        monthNamesShort: [ "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic" ]

    });
   
    
		
});


function pa_eliminar(id_paciente)
{
    var base_url = $('#base_url').val()
    //Bloquear la pantalla en negro y mostrar la imagen loading..
    $.blockUI({
        message: '<img src="'+base_url+'images/ajax-loader.gif" />'
    });
    $('#myModal').modal('show');
    $('#cancelar').click(function(){
        $.unblockUI();
    })
    $('#eliminar').click(function(){
        var datos={
            id_paciente:id_paciente
        }
        //AJAX
        $.ajax({
            url: base_url+"pacientes/delete/",
            type: 'POST',
            data: datos,
            success: function(msg) {
                $('#pa_'+id_paciente).hide();
                $('#myModal').modal('hide');
                $.unblockUI();
            }
        })
       
    });
    
    
   
}